<template>
    <div class="common-body-wrapper">
        <search-header single-width="130" :searchList="searchList" @changeHeight="toRetTable" @confirmSearch="toSearch" @handleChange="handleSearchChange"
        :isNeedTree="true" :isCheckbox="true" :paramName="paramName" @setSelectedNode="setSelectedNode"></search-header>
        <div class="common-table-tree-wrapper">
            <div class="common-table-wrapper">
                <multi-fun-table :sortColumn='notFormatColumn' :orderType='sortType' :fixed-cols="fixedCols" :is-reset-table="isResetTable" :theads-info="theadsInfo" :tbodys-info="tbodysInfo" @handleMultiCheck="handleMultiCheck" @handleSortColumn="handleSortColumn" @searchFn="getList" @getNextPage="getNextPage">
                    <!--按钮-->
                    <div class="operate-btn-group" slot="operateBtnGroup">
                        <a class="ake_btn ake_btn_text" v-if="isPermmited('SCORE:DAILYREPORT:EXPORT')" @click.prevent="exportReport()">导出</a>
                    </div>

                    <!--普通列-->
                    <template slot="tdCell" slot-scope="props">
                        <el-table-column :fixed="props.fixed" :label="props.label" :min-width="props.minWidth" :width="props.width" :prop="props.prop" :sortable="props.sortable">
                            <template slot-scope="scope">
                                <span v-if="'reno' == props.prop&&scope.$index!==0">{{ scope.$index }}</span>
                                <span v-else-if="'reno' == props.prop&&scope.$index==0">合计</span>
                                <span v-else-if="'reliefValue' == props.prop">{{ scope.row.reliefValue |formatMoney }}</span>
                                <span v-else :title="scope.row[props.prop]">{{ scope.row[props.prop] }}</span>
                            </template>
                        </el-table-column>
                    </template>

                    <!--操作列内的按钮-->
                    <template slot="operateCell" slot-scope="props">
                        <el-table-column :fixed="props.fixed" :label="props.label" width="100" class="operateCell">
                            <template slot-scope="scope">
                                <el-button v-if="isPermmited('SCORE:DAILYREPORT:RECREATE') &&scope.$index!==0" size="small" type="primary" icon="icon-synchronize" class="ake-icon-font" title="重新同步" @click="toCreate(scope.row)" plain></el-button>
                                <el-button v-if="isPermmited('SCORE:DAILYREPORT:EXPORT_DETAIL') &&scope.$index!==0" size="small" type="primary" icon="icon-export" class="ake-icon-font" title="导出详情" @click="exportReportDetail(scope.row)" plain></el-button>
                            </template>
                        </el-table-column>
                    </template>
                </multi-fun-table>

                <!---->
                <table-pagination :size="total" :cur-page="pageNumber" @backData="getPagination"></table-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import common from "@mixins/common.js";
import stardardList from "@mixins/tables/stardardList.js";

//modal
import invokeModal from "@mixins/modal/invokeModal.js";

// 引进vue的js
import js from "./js/report.js";

export default {
  name: 'scoreReport',
  mixins: [common, stardardList, invokeModal, js],
  data() {
    var today = [new Date(moment().subtract('days', 1).format("YYYY-MM-DD 00:00:00")), new Date(moment().subtract('days', 1).format("YYYY-MM-DD 23:59:59"))]; //昨天
    return {
      total: 0,
      fixedCols: 4,
      paramName: "parkIds",
      searchList: [
        {
          index: 0,
          isShow: false,
          type: "select",
          name: "reportDimension",
          text: "时间维度",
          value: "day",
          isHandleChange: true,
          options: [
            { name: "日报", value: "day" },
            { name: "月报", value: "month" },
            { name: "年报", value: "year" },
            { name: "自定义", value: "custom" }
          ]
        },
        {
          index: 1,
          format: "yyyy-MM-dd",
          isShow: false,
          type: "datePicker",
          pickerType: "daterange",
          name: "dateFromTo",
          text: "时间区间",
          propName: "statDateFromStr,statDateToStr",
          value: today,
          style: { width: "360px" },
        },
      ],
      theadsInfo: [
        // { index: 0, isShow: false, prop: "reno", text: "序号", width: 68 },
        {
          index: 1,
          isShow: false,
          prop: "date4ExportStr",
          text: "日期",
          minWidth: 80
        },
        {
          index: 2,
          isShow: false,
          prop: "parkName",
          text: "停车场",
          minWidth: 60
        },
        {
          index: 3,
          isShow: false,
          prop: "reliefScore",
          text: "抵扣积分总数",
          minWidth: 50
        },
        {
          index: 4,
          isShow: false,
          prop: "reliefScoreTimes",
          text: "抵扣积分总次数",
          minWidth: 50
        },
        {
          index: 5,
          isShow: false,
          prop: "reliefValue",
          text: "车场积分总金额",
          minWidth: 50
        }
      ],
      tbodysInfo: []
    };
  }
};
</script>

<style lang="less">
.config-modal {
  padding-bottom: 30px;
  .first-item {
    width: 240px;
  }
  .modal-body {
    // max-height: 500px;
    // min-height: 300px;
    overflow-y: scroll;
  }
  .select-park-textarea {
    display: block;
    margin-top: 10px;
    color: #333;
  }
  .el-textarea.is-disabled .el-textarea__inner {
    color: #333 !important;
  }
  .config-rule {
    width: 120px;
  }
}
</style>
